typedef struct {
	int fd;
	struct sockaddr_in sa;
	socklen_t sa_len;
}conn_t;

//the base header of packet (limit 1 bytes)
typedef struct {
	uint8_t qos:1;//qos level
	uint8_t type:5;//messages type
	uint8_t len:2;//the length len
}p_head;

enum type {
	RESERVE = 0,
	CONNECT = 1,
	CONNACK = 2
};

//connect struct
typedef struct {
		uint8_t ver;
		//ecdh
		EccPoint pub_key;
		uint8_t random[NUM_ECC_DIGITS];
}p_connect;

typedef struct {
		uint8_t state;
		uint8_t random[NUM_ECC_DIGITS];
}p_connack;

enum state {
	SUCCESS = 0,//connect success
	FAILED = 1,//connect failed
	UNKNOW_PROTOCOL = 2,
	SECRET_INVAILD = 3,
	SERVER_ERROR = 4,
};

typedef struct {
		uint8_t *id;//session id
		size_t id_len;//session id length
		struct sockaddr_in sa;//session addr
		//ecdh
		uint8_t w[Nb*(Nr+1)*4];//aes expansion key
		uint8_t random[NUM_ECC_DIGITS];//client random number
		struct client_t *next;
}client_t;




